<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: account_delete.php 438 2014-01-19 11:50:30Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 438 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2014-01-19 11:50:30 +0000 (Sun, 19 Jan 2014) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */
 define('GLOBAL_COLUMN_LEFT', '0');
include ('includes/application_top.php');

$smarty = new Smarty;

require(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');

if(!isset($_SESSION['customer_id']))
	redirect(href_link(FILENAME_LOGIN, '', 'SSL'));

if($_SESSION['customer_id'] == 1)
	redirect(href_link(FILENAME_ACCOUNT, '', 'SSL'));

if (isset ($_POST['action']) && ($_POST['action'] == 'process')) {
	$delete_customer_query = $db->db_query("INSERT 
												INTO 
													".TABLE_CUSTOMERS_SIK." 
												SELECT 
													* 
												FROM 
													".TABLE_CUSTOMERS." 
												WHERE 
													customers_id = '".(int)$_SESSION['customer_id']."'");
													
    $db->db_query("DELETE FROM 
						".TABLE_CUSTOMERS." 
					WHERE 
						customers_id = '".(int)$_SESSION['customer_id']."'");
    											
	$db->db_query("DELETE FROM 
						".TABLE_NEWSLETTER_RECIPIENTS." 
					WHERE 
						customers_id = '".(int) $_SESSION['customer_id']."'");
						
    session_destroy();
    unset($_SESSION['customer_id']);
    unset($_SESSION['customer_default_address_id']);
    unset($_SESSION['customer_first_name']);
    unset($_SESSION['customer_country_id']);
    unset($_SESSION['customer_zone_id']);
    unset($_SESSION['comments']);
    unset($_SESSION['user_info']);
    unset($_SESSION['customers_status']);
    unset($_SESSION['selected_box']);
    unset($_SESSION['navigation']);
    unset($_SESSION['shipping']);
    unset($_SESSION['payment']);
    unset($_SESSION['ccard']);
    // GV Code Start
    unset($_SESSION['gv_id']);
    unset($_SESSION['cc_id']);
    // GV Code End
    $_SESSION['cart']->reset();

    $smarty->assign('BUTTON_CONTINUE', '<a href="'.href_link(FILENAME_DEFAULT, '', 'NONSSL').'">'.image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE).'</a>');
}

$breadcrumb->add(NAVBAR_TITLE_1_ACCOUNT_DELETE, href_link(FILENAME_ACCOUNT, '', 'SSL'));
$breadcrumb->add(NAVBAR_TITLE_2_ACCOUNT_DELETE, href_link(FILENAME_ACCOUNT_DELETE, '', 'SSL'));

require (DIR_WS_INCLUDES.'header.php');

$smarty->assign('FORM_ACTION', draw_form('account_delete', href_link(FILENAME_ACCOUNT_DELETE, '', 'SSL'), 'post'). draw_hidden_field('action', 'process'));

$smarty->assign('BUTTON_BACK', '<a href="'.href_link(FILENAME_ACCOUNT, '', 'SSL').'">'.image_button('button_back.gif', IMAGE_BUTTON_BACK).'</a>');
$smarty->assign('BUTTON_SUBMIT', image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE));
$smarty->assign('FORM_END', '</form>');

$smarty->assign('language', $_SESSION['language']);

$smarty->caching = false;
$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/account_delete.html');

$smarty->assign('language', $_SESSION['language']);
$smarty->assign('main_content', $main_content);
$smarty->caching = false;
if (!defined('RM'))
    $smarty->loadFilter('output', 'note');
$smarty->loadFilter('output','trimwhitespace');
$smarty->display(CURRENT_TEMPLATE.'/index.html');
include ('includes/application_bottom.php');
?>